//package com.woniuxy.carlife.carlifeuserweb.controller;

//
//import cn.hutool.core.util.ObjectUtil;
//import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
//import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.Result;
//import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.StatusCode;
//import com.woniuxy.carlife.carlifecommonsweb.util.CopyUtil;
//import com.woniuxy.carlife.carlifecommonsweb.util.JwtUtil;
//import com.woniuxy.carlife.carlifeusermodel.dto.ChargingStationfavoritesDto;
//import com.woniuxy.carlife.carlifeusermodel.dto.ShoppingcartDto;
//import com.woniuxy.carlife.carlifeusermodel.param.ChargingStationfavoritesParam;
//import com.woniuxy.carlife.carlifeuserweb.entity.ChargingStationfavorites;
//import com.woniuxy.carlife.carlifeuserweb.entity.Shoppingcart;
//import com.woniuxy.carlife.carlifeuserweb.service.ChargingStationfavoritesService;
//import com.woniuxy.carlife.carlifeuserweb.util.StatusMessageEnum;
//import io.jsonwebtoken.Claims;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * @author zjq
// * @ClassName:c
// * @Description:充电站收藏
// * @date 2021/4/6 20:02
// **/
//
//@RestController
//@RequestMapping("/charging-stationfavorites")
//@Api(tags = "充电站收藏")//用于描述接口类的相关信息，作用于类上
//public class ChargingStationfavoritesController {
//
//    @Resource
//    ChargingStationfavoritesService chargingStationfavoritesService;
//
//
//    /*
//     * 功能描述〈查询充电站收藏根据用户id〉
//     * @author:zjq
//     * @param:
//     * @return:
//     * @Date 2021/4/12 14:34
//     * @throws
//     */
//
//    @ApiOperation(value = "查询充电站收藏")
//    @GetMapping("/ordinary/findChargingStationfavoritesByUserId")
//    public Result findChargingStationfavoritesByUserId() {
//        ServletRequestAttributes sra =
//                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        String token = sra.getRequest().getHeader("token");
//        JwtUtil jwtUtil = new JwtUtil();
//        Claims claims = jwtUtil.parseTokenOrdinary(token);
//        if (claims == null) {
//
//            return new Result(false, StatusCode.NOT_LOGGED_IN, StatusMessageEnum.NOT_LOGGED_IN.toString());
//        }
//        Object o = claims.get("token");
//        Integer tokenUserId = Integer.valueOf(String.valueOf(o));
//        List<ChargingStationfavorites> chargingStationfavoritesByUserId = chargingStationfavoritesService.findChargingStationfavoritesByUserId(tokenUserId);
//
//
//        if (ObjectUtil.isNull(chargingStationfavoritesByUserId)) {
//            return new Result(false, StatusCode.QUERY_IS_EMPTY, StatusMessageEnum.QUERY_IS_EMPTY.toString());
//        }
//
//        List<ChargingStationfavoritesDto> chargingStationfavoritesList = CopyUtil.getList(chargingStationfavoritesByUserId, ChargingStationfavoritesDto.class);
//
//        return new Result(true, StatusCode.SEARCH_SUCCESSFUL, StatusMessageEnum.SEARCH_SUCCESSFUL.toString(), chargingStationfavoritesList);
//    }
//
//    /*
//     * 功能描述〈新增充电站收藏〉
//     * @author:zjq
//     * @param:
//     * @return:
//     * @Date 2021/4/14 20:03
//     * @throws
//     */
//    @ApiOperation(value = "新增充电站收藏")
//    @PostMapping("/ordinary/addChargingStationfavoritesBytChargingStationfavoritesId")
//    public Result addChargingStationfavoritesBytChargingStationfavoritesId(@ApiParam ChargingStationfavoritesParam chargingStationfavoritesParam) {
//        ServletRequestAttributes sra =
//                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        String token = sra.getRequest().getHeader("token");
//        JwtUtil jwtUtil = new JwtUtil();
//        Claims claims = jwtUtil.parseTokenOrdinary(token);
//        if (claims == null) {
//
//            return new Result(false, StatusCode.NOT_LOGGED_IN, StatusMessageEnum.NOT_LOGGED_IN.toString());
//        }
//        Object o = claims.get("token");
//        Integer tokenUserId = Integer.valueOf(String.valueOf(o));
//        if (ObjectUtil.isNull(chargingStationfavoritesParam)) {
//            return new Result(false, StatusCode.CAN_NOT_BE_EMPTY, StatusMessageEnum.CAN_NOT_BE_EMPTY.toString());
//
//        }
//
//        ChargingStationfavorites one = CopyUtil.getOne(chargingStationfavoritesParam, ChargingStationfavorites.class);
//        one.setUserId(tokenUserId);
//        Boolean aBoolean = chargingStationfavoritesService.addChargingStationfavoritesBytChargingStationfavoritesId(one);
//        return aBoolean ?
//                new Result(true, StatusCode.ADDED_SUCCESSFULLY, StatusMessageEnum.ADDED_SUCCESSFULLY.toString())
//                : new Result(false, StatusCode.ADD_FAILED, StatusMessageEnum.ADD_FAILED.toString());
//
//
//    }


//}

